/*
 * Copyright (c) 2022 Huawei Device Co., Ltd.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#ifndef _OLA_PAL_STORE_H_
#define _OLA_PAL_STORE_H_

#ifdef __cplusplus
extern "C" {
#endif


/*
 * 功能: 存储初始化
 * 返回: 0，初始化成功
 *       -1，初始化失败
 */
int OlaStoreInit(void);

/*
 * 功能: 存储去初始化
 * 返回: 0，去初始化成功
 *       -1，去初始化失败
 */
int OlaStoreDeinit(void);

/*
 * 功能: 根据索引key存储value数据，需保证数据与索引关系掉电不丢失
 * 参数: key，待存储数据的索引
 *       value，待存储的数据
 *       len，待存储数据的长度
 * 返回: 0，表示存储成功
 *       -1，表示存储失败
 */
int OlaStoreSet(const char *key, const unsigned char *value, unsigned int len);

/*
 * 功能: 根据索引key读取value数据
 * 参数: key，存储数据的索引
 *       value，待读取的数据缓冲区
 *       len，出入参，入参表示缓冲区长度，出参表示读取到的数据长度
 * 返回: 0，表示读取成功
 *       -1，表示读取失败
 */
int OlaStoreGet(const char *key, unsigned char *value, unsigned int *len);

/*
 * 功能: 根据索引key擦除数据
 * 参数: key，存储数据的索引
 * 返回: 0，擦除成功
 *       -1，擦除失败
 */
int OlaStoreDel(const char *key);

#ifdef __cplusplus
}
#endif

#endif /* _OLA_PAL_STORE_H_ */